home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / qt_put.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  52 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / Append object to the rear of the process_queue.
  8. / If necessary, pause and loop until
  9. / room becomes available.
  10. nt queue_tail::put(process_object *p)
  11.  
  12.    if (debug) /*DELETE*/ cerr << "queue_tail" << this << "::put()\n";
  13.    register process_queue *q = qt_queue;
  14.  
  15.    while (q->q_count >= q->q_max)
  16. switch (qt_mode)
  17.     {
  18.     case Q_WMODE:
  19.     this_process()->pause(this);
  20.     break;
  21.  
  22.     case Q_EMODE:
  23.     error("queue_head::put(): full queue");
  24.     break;
  25.  
  26.     case Q_ZMODE:
  27.         if (debug) /*DELETE*/ cerr << "<<<< queue_tail" << this << "::put() <- 0\n";
  28.     return 0;
  29.     }
  30.  
  31.    if (p->po_next)
  32. error("queue_tail::put(): object on another queue");
  33.  
  34.    // new object on empty queue
  35.    if (q->q_count++ == 0)
  36. {
  37. q->q_last = p->po_next = p;
  38. if (q->q_head) q->q_head->alert();
  39. }
  40.  
  41.    // objects are already on the queue
  42.    else
  43. {
  44. process_object *last = q->q_last;
  45. p->po_next = last->po_next;
  46. q->q_last = last->po_next = p;
  47. }
  48.  
  49.    if (debug) /*DELETE*/ cerr << "<<<< queue_tail" << this << "::put() <- 1\n";
  50.    return 1;
  51.  
  52.